
####################Separate Analysen f?r power separation and media control##############################


rm(list = ls())


data <- read_excel("Data/2_data_final_power_sep.xlsx")

data_europe <- data %>% 
  subset(region=="Europe" &  (polity>=6 | is.na(polity))) #Ukraine drops out

DQ_all <- c("gdp_pc", "DQ_new", "INDLIB_new", "MUTUCONS_new", "RULEOFLAW_new", "PUBLIC_new", "dem_courts_perc", "dem_courts", "dem_support", "dem_support_perc", "civ_rights_support", "civil_rights_perc")

###################################################################
#Not in manucscript: only to check variation
#scatterplot: media control and power concentration
####################################################################


ggplot(data, aes(x=power_concentration_index, y=media_control_index))+
  geom_point()+
  geom_smooth(method = "lm")+
  geom_text_repel(aes(label = country_DB),
                  size = 5, show.legend=FALSE)+
  xlab("Power concentration index") + 
  ylab("Media control index")+
  theme(axis.text=element_text(size=12),
        axis.title=element_text(size=18)) +
  scale_y_continuous(limits = c(-2.5, 7.5), breaks = c(-2.5, 0, 2.5, 5, 7.5))+
  scale_x_continuous(limits = c(-2.5, 5), breaks = c(-2.5, 0, 2.5, 5))

###################################################################
#Appendix: Table 3 with power_concentration_index without media
####################################################################


#without backsliding
model111 <- lm(power_concentration_index~ DQ_new + hospital_beds + gdp_pc, data = data_europe)
summary(model111)
model222 <- lm(power_concentration_index ~ INDLIB_new + hospital_beds + gdp_pc, data = data_europe)
summary(model222)
model333 <- lm(power_concentration_index ~ RULEOFLAW_new + hospital_beds + gdp_pc, data = data_europe)
summary(model333)
model444 <- lm(power_concentration_index ~ MUTUCONS_new + hospital_beds + gdp_pc, data = data_europe)
summary(model444)


screenreg(list(model111,model222,model333, model444),
          stars = c(0.01,0.05,0.1))

screenreg(list(model111,model222,model333, model444),
          stars = c(0.01,0.05,0.1),
          custom.model.names = c("Model 2.1", "Model 2.2", "Model 2.3", "Model 2.4"),
          reorder.coef = c(2, 5, 6, 7, 3, 4, 1), 
          custom.coef.names = c("Intercept", "Quality of Democracy", "# of hospital beds", "GDP per capita", "Individual liberties", "Rule of law", "Mutual constraints")) 


htmlreg(list(model111,model222,model333, model444),
        stars = c(0.01,0.05,0.1),
        custom.model.names = c("Model 2.1", "Model 2.2", "Model 2.3", "Model 2.4"),
        reorder.coef = c(2, 5, 6, 7, 3, 4, 1), 
        custom.coef.names = c("Intercept", "Quality of Democracy", "# of hospital beds", "GDP per capita", "Individual liberties", "Rule of law", "Mutual constraints"),
        include.loglik = FALSE, include.deviance = FALSE, include.aic = FALSE, include.bic = FALSE,
        file="Out/TableA13_app.html")

###################################################################
#Appendix: Table appendix with media control index
####################################################################


#without backsliding
model111m <- lm(media_control_index~ DQ_new + hospital_beds + gdp_pc, data = data_europe)
summary(model111m)
model222m <- lm(media_control_index ~ INDLIB_new + hospital_beds + gdp_pc, data = data_europe)
summary(model222m)
model333m <- lm(media_control_index ~ RULEOFLAW_new + hospital_beds + gdp_pc, data = data_europe)
summary(model333m)
model444m <- lm(media_control_index ~ MUTUCONS_new + hospital_beds + gdp_pc, data = data_europe)
summary(model444m)


screenreg(list(model111m,model222m,model333m, model444m),
          stars = c(0.01,0.05,0.1))

screenreg(list(model111m,model222m,model333m, model444m),
          stars = c(0.01,0.05,0.1),
          custom.model.names = c("Model 2.1", "Model 2.2", "Model 2.3", "Model 2.4"),
          reorder.coef = c(2, 5, 6, 7, 3, 4, 1), 
          custom.coef.names = c("Intercept", "Quality of Democracy", "# of hospital beds", "GDP per capita", "Individual liberties", "Rule of law", "Mutual constraints")) 


#htmlreg(list(model111m,model222m,model333m, model444m),
        #stars = c(0.01,0.05,0.1),
        #custom.model.names = c("Model 2.1", "Model 2.2", "Model 2.3", "Model 2.4"),
        #reorder.coef = c(2, 5, 6, 7, 3, 4, 1), 
        #custom.coef.names = c("Intercept", "Quality of Democracy", "# of hospital beds", "GDP per capita", "Individual liberties", "Rule of law", "Mutual constraints"),
        #include.loglik = FALSE, include.deviance = FALSE, include.aic = FALSE, include.bic = FALSE,
        #file="Table_app_media.html")

